local assets =
{
    Asset("ANIM", "anim/brilliance_projectile_fx.zip"),
}
local prefabs = {
    "hitsparks_piercing_fx",
}
local function OnHit(inst, attacker, target)
    -- 击中特效
    local fx = SpawnPrefab("hitsparks_piercing_fx")
    if fx ~= nil then
        fx.Transform:SetPosition(inst.Transform:GetWorldPosition())
    end
    if attacker ~= nil and attacker:IsValid() and attacker.components.health ~= nil and attacker.components.health.currenthealth > 0 then
        attacker.SoundEmitter:PlaySound("sound/dontstarve.fev")     --酷酷的攻击音效
    end
    inst:Remove()
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()
    -- inst.entity:AddPhysics()

    MakeInventoryPhysics(inst)
    RemovePhysicsColliders(inst)--移除碰撞专用

    inst.AnimState:SetBank("brilliance_projectile_fx")
    inst.AnimState:SetBuild("brilliance_projectile_fx")
    inst.AnimState:PlayAnimation("idle_loop")

    inst:AddTag("projectile")

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("projectile")
    inst.components.projectile:SetSpeed(25)                            -- 飞行速度
    inst.components.projectile:SetHitDist(1.5)                         -- 判定距离
    inst.components.projectile:SetOnHitFn(OnHit)
    inst.components.projectile:SetOnMissFn(function(i) i:Remove() end) -- 如果没击中直接消失
    inst.components.projectile:SetHoming(false)

    return inst
end

return Prefab("starry_shoot_projectile", fn, assets, prefabs)
